#include <functions\core_macros.h>

private ["_side"];

["TYR"] call IFUNC(register);

if (isServer) then {
	GVAR(AVAILABLE_VEHICLES) = TYR_AirDrop_Quantity;
	publicVariable QGVAR(AVAILABLE_VEHICLES);
	GVAR(TRANSPORTER_IN_THE_AIR) = false;
	publicVariable QGVAR(TRANSPORTER_IN_THE_AIR);
	
	// Server only initialization
	["TYR",QGVAR(CALLDROP),QUOTE(FUNC(pveh))] call IFUNC(handlerAdd);
};
	
GVAR(MAX_DROP_DIST) = TYR_AirDrop_MaxDist;
GVAR(WITH_VEHICLE) = TYR_AirDrop_Vehicles > 0;
GVAR(WITH_AMMO) = TYR_AirDrop_Ammunitions > 0;
GVAR(WITH_STATIC) = TYR_AirDrop_Statics > 0;
GVAR(WITH_SMOKESHELL) = TYR_AirDrop_Smokeshell > 0;
GVAR(AIR_DROP_START_POINT) = [];
if (IS_MARKER("TYR_AIRDROP_START")) then {
	GVAR(AIR_DROP_START_POINT) = markerPos "TYR_AIRDROP_START";
};

if (isDedicated || !hasInterface) exitWith {};

// Player only initialization
["TYR",QGVAR(INFORMPLAYER),QUOTE(FUNC(pveh))] call IFUNC(handlerAdd);

if (isnil "PAPABEAR") then { PAPABEAR = [playerSide,"HQ"]; };

_side = switch (playerSide) do {
	case west : { str(west); };
	case blufor : { str(west); };
	case east : { str(east); };
	case opfor : { str(east); };
	case resistance : { str(resistance); };
	case civilian : { str(civilian); };
	default { str(west); };
};

if (isNil QGVAR(VEHICLE_LIST)) then {
	call compile format["%1 = %1_%2;",QGVAR(VEHICLE_LIST),_side];
};
if (isNil QGVAR(STATIC_LIST)) then {
	call compile format["%1 = %1_%2;",QGVAR(STATIC_LIST),_side];
};
if (isNil QGVAR(DROPVEHICLE_TYPE)) then {
	call compile format["%1 = %1_%2;",QGVAR(DROPVEHICLE_TYPE),_side];
};
if (isNil QGVAR(BOX_TYPE)) then {
	call compile format["%1 = %1_%2;",QGVAR(BOX_TYPE),_side];
};

if (!isDedicated) then {
	if (isNil "TYR_MENU_IsActive" || {TYR_MENU_IsActive <= 0}) then {
		["player", [mso_interaction_key], -9406, ["tmf\support\modules\tyr_airdrop\fn_menuDef.sqf", "main"]] call CBA_ui_fnc_add;
		[localize "STR_TYR_DROP_MENU_RADIO","if(if (!isnil 'mp_rights_fnc_hasRoles') then { [(getPlayerUID player),['leader','admin','airdrop']] call mp_rights_fnc_hasRoles} else { true }) then {createDialog ""TYR_DROP_airdrop_ui""}"] call mso_core_fnc_updateMenu;
	} else {
		if (!isnil "tyr_fnc_addHandler") then {
			["TYRMENU",
				[[
					localize "STR_TYR_DROP_MENU_RADIO"
					,{if (!isnil "mp_rights_fnc_hasRoles") then { [(getPlayerUID player),['leader','admin','airdrop']] call mp_rights_fnc_hasRoles} else { true }}
					,{createDialog "TYR_DROP_airdrop_ui"}
					,"tmf\support\modules\tyr_airdrop\parachute.paa"
				]]
			] call tyr_fnc_addHandler;
		};
	};
};